package com.sdry.web.controller.llm;

import java.util.List;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.sdry.model.llm.LlmCancellingStockReason;
import com.sdry.model.lz.Customer;
import com.sdry.model.lz.Warehouse;
import com.sdry.service.llm.CancellingStockReasonService;
import com.sdry.service.llm.CancellingStockService;
import com.sdry.service.lz.StockOutOrderService;
import com.sdry.service.tdd.OthersService;

/**
 * 路径管理                              多仓库修改  t  2019-11-01 
 * 39-43	加载OthersService
 * 50-66	跳转页面：修改根据session中仓库id查询供应商方法
 * @Title:PathManagerment
 * @Package com.sdry.web.controller.llm
 * @author llm
 * @date 2019年5月14日
 * @version 1.0
 */
@Controller
@RequestMapping("/path")
public class PathManagerment {
	@Resource StockOutOrderService stockOutOrderService;
	@Resource
	private CancellingStockService cancellingStockService;
	@Resource
	private CancellingStockReasonService cancellingStockReasonService;
	/* ******************************多仓库修改  t  2019-11-01 开始*************************** */
	//加载OthersService
	@Resource
	private OthersService othersService;
	/* ******************************多仓库修改  t  2019-11-01 结束*************************** */
	
	/**
	 * 进入退库单管理
	 * @return
	 */
	@RequestMapping(value="/toCancellingStocksManager")
	/* ******************************多仓库修改  t  2019-11-01 开始*************************** */
	//多仓库修改之前：public ModelAndView toCancellingStocksManager(){
	public ModelAndView toCancellingStocksManager(HttpSession httpSession){
		//多仓库修改之前：
		ModelAndView mv = new ModelAndView();
		//多仓库修改之前：List<Customer> customerList = cancellingStockService.getAllCustomer();
		//从session中获取仓库
		Long warehouse_id = (Long) httpSession.getAttribute("warehouse_id");
		//创建客户实体
		Customer param = new Customer();
		//赋值仓库id
		param.setWarehouse_id(warehouse_id);
		//赋值客户类型 0供应商  1主机场
		param.setCustomer_type("0");
		//根据客户实体为条件查询对应客户集合
		List<Customer> customerList = othersService.customerQueryAllByMution(param);
		/* ******************************多仓库修改  t  2019-11-01 结束*************************** */
		mv.addObject("customerList", customerList);
		List<LlmCancellingStockReason> reasonList = cancellingStockReasonService.getAllCancellingStockReason();
		mv.addObject("reasonList", reasonList);
		List<Warehouse> allWarehouse = cancellingStockService.getAllWarehouse();
		mv.addObject("warehouseList", allWarehouse);
		mv.setViewName("/llm/CancellingStocksManager4");
		return mv;
	}
	
	/**
	 * 跳转退库原因页面
	 * @return
	 */
	@RequestMapping(value="/toCancellingStockReasonManager")
	public ModelAndView toCancellingStockReasonManager(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/cancellingStockReason");
		return mv;
	}
	
	/**
	 * 跳转退库月报表页面
	 * @return
	 */
	@RequestMapping(value="/toCancellingStockMonthReport")
	public ModelAndView toCancellingStockMonthReport(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/cancellingStockMonthReport");
		return mv;
	}
	
	/**
	 * 跳转退库周报表页面
	 * @return
	 */
	@RequestMapping(value="/toCancellingStockWeekReport")
	public ModelAndView toCancellingStockWeekReport(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/cancellingStockWeekReport");
		return mv;
	}
	
	/**
	 * 跳转出库月报表页面
	 * @return
	 */
	@RequestMapping(value="/toOutStockMonthReport")
	public ModelAndView toOutStockMonthReport(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/outStockMonthReport");
		return mv;
	}
	
	/**
	 * 跳转出库周报表页面
	 * @return
	 */
	@RequestMapping(value="/toOutStockWeekReport")
	public ModelAndView toOutStockWeekReport(){
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/outStockWeekReport");
		return mv;
	}
	
	/**
	 * 跳转绑码记录
	 * @return
	 */
	@RequestMapping(value="/toCodemark")
	public ModelAndView toCodemark(Model model){
		List<Customer> customer_type0 = stockOutOrderService.queryAllCustomerByType();
		model.addAttribute("customer_type0", customer_type0);
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/queryCodemark");
		return mv;
	}
	
	/**
	 * 跳转拆箱记录
	 * @return
	 */
	@RequestMapping(value="/toDevaning")
	public ModelAndView toDevaning(Model model){
		List<Customer> customer_type0 = stockOutOrderService.queryAllCustomerByType();
		model.addAttribute("customer_type0", customer_type0);
		ModelAndView mv = new ModelAndView();
		mv.setViewName("/llm/devaning");
		return mv;
	}
}
